
#include<iostream>
#include<vector>
using namespace std;


int main()
{
    int n; cin >> n;
    vector<int>arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    int start = 0; int max_len = 0;
    int left = 0; int right = 0;
    while (right < n)
    {
        while (right+1<n&&arr[right + 1] > arr[right])
            right++;
        //判断长度是否需要更新
        if (right - left + 1 > max_len)
        {
            start = left;
            max_len = right - left + 1;
        }
        right++;
        left = right;
    }

    for (int i = start; i < start+max_len; i++)
        cout << arr[i] << " ";
    return 0;
}

